package com.ruoyi.fee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fee.domain.PropertyBill;
import com.ruoyi.fee.service.IPropertyBillService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 账单信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/fee/bill")
public class PropertyBillController extends BaseController
{
    @Autowired
    private IPropertyBillService propertyBillService;

    /**
     * 查询账单信息列表
     */
    @PreAuthorize("@ss.hasPermi('fee:bill:list')")
    @GetMapping("/list")
    public TableDataInfo list(PropertyBill propertyBill)
    {
        startPage();
        List<PropertyBill> list = propertyBillService.selectPropertyBillList(propertyBill);
        return getDataTable(list);
    }

    /**
     * 导出账单信息列表
     */
    @PreAuthorize("@ss.hasPermi('fee:bill:export')")
    @Log(title = "账单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyBill propertyBill)
    {
        List<PropertyBill> list = propertyBillService.selectPropertyBillList(propertyBill);
        ExcelUtil<PropertyBill> util = new ExcelUtil<PropertyBill>(PropertyBill.class);
        util.exportExcel(response, list, "账单信息数据");
    }

    /**
     * 获取账单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('fee:bill:query')")
    @GetMapping(value = "/{billId}")
    public AjaxResult getInfo(@PathVariable("billId") Long billId)
    {
        return success(propertyBillService.selectPropertyBillByBillId(billId));
    }

    /**
     * 新增账单信息
     */
    @PreAuthorize("@ss.hasPermi('fee:bill:add')")
    @Log(title = "账单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyBill propertyBill)
    {
        return toAjax(propertyBillService.insertPropertyBill(propertyBill));
    }

    /**
     * 修改账单信息
     */
    @PreAuthorize("@ss.hasPermi('fee:bill:edit')")
    @Log(title = "账单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyBill propertyBill)
    {
        return toAjax(propertyBillService.updatePropertyBill(propertyBill));
    }

    /**
     * 删除账单信息
     */
    @PreAuthorize("@ss.hasPermi('fee:bill:remove')")
    @Log(title = "账单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billIds}")
    public AjaxResult remove(@PathVariable Long[] billIds)
    {
        return toAjax(propertyBillService.deletePropertyBillByBillIds(billIds));
    }
}
